App.Presenter.CustomPagePresenter = (function (App) {

    var _router = App.Router;
    var _page = App.View.CustomPage;
    var _view = App.View;
    var _cache = App.Data.Cache;

    // 页面操作类型
    var ACTION_TYPE = {
        DETAILS:0, // 客户详情
        ADD:1              // 添加客户
    };
    var _action;
    var _custom;

    var onLoad = function (page_id) {
        _page.loadPage(page_id);
    };

    var setData = function (data) {
        if (data) {
            _action = data.action || ACTION_TYPE.DETAILS;
            _custom = data.custom;
            _parseAction();
        }
    };

    var _parseAction = function () {
        switch (_action) {
            case ACTION_TYPE.DETAILS:
                _view.Helper.setTitle('客户详情');
                _page.showCustomDetails(_custom);
                break;
            case ACTION_TYPE.ADD:
                _view.Helper.setTitle('添加客户');
                _page.showAddCustom();
                break;
        }
    };

    return {
        ACTION_TYPE:ACTION_TYPE,
        onLoad:onLoad,
        setData:setData
    };

})(App);

// 注册展示器
App.Presenter.register(PAGE_CUSTOM, App.Presenter.CustomPagePresenter);